var searchRange = function(nums, target) {
    let left=0,
        right=nums.length-1
    let ans =[-1,-1]
    while(left<=right){
        var mid = Math.floor((left+right)/2)
        if(nums[mid]==target){
            let minTarget = mid-1,
                maxTarget = mid+1
            while(nums[minTarget]==target&&minTarget>=left){
                minTarget--
            }
            while(nums[maxTarget]==target&&maxTarget<=right){
                maxTarget++
            }
        
            return [minTarget+1,maxTarget-1]

        }else if(nums[mid]>target){
            right=mid-1
        }else{
            left=mid+1
        }
    }
    return [-1,-1]

};